package com.wthink.newMain.settings.version

import android.os.Build
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wthink.hzgj.data.Result
import com.wthink.hzgj.data.domain.DeviceVersion
import com.wthink.hzgj.data.domain.VersionInfos
import com.wthink.hzgj.service.DevService
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class VersionViewmodel : ViewModel(){
    val version = MutableLiveData<String>()
    val devVersion = MutableLiveData<VersionInfos>()
    fun start(){
        getVersion()
        viewModelScope.launch(Dispatchers.IO) {
            val ret = DevService.queryDevVersion()
            if (ret is Result.Success) {
                devVersion.postValue(ret.data)
            }
        }
    }

    fun getVersion(){
        version.postValue(Build.VERSION.RELEASE)
    }

}